# This is just meant to be a minimal makefile to bootstrap CAnt2 until it can build itself.

#OPTIMIZATION_FLAGS=-O2 -Zi
OPTIMIZATION_FLAGS=-Zi
CANT2_CPPFLAGS=-nologo -W4 -WX -Wp64 -EHsc -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE $(OPTIMIZATION_FLAGS)
UNITTESTPP_CPPFLAGS=-nologo -W4 -WX -Wp64 -EHsc -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -I.. $(OPTIMIZATION_FLAGS)

##############################################################################

CANT2_CORE_SOURCES=\
	./src/core/xml.cpp				\
	./src/core/XmlCharacterClassification.cpp	\
	./src/core/StringPool.cpp			\
	./src/core/MiniXmlDOM.cpp			\

CANT2_MAIN_SOURCES=\
	./src/main/main.cpp				\

CANT2_TEST_SOURCES=\
	./test/UnitTestMain.cpp				\
	./test/XmlParserTests.cpp			\
	./test/XmlCharacterClassificationTests.cpp  	\
	./test/HashTableTests.cpp  			\
	./test/StringPoolTests.cpp  			\
	./test/MiniXmlDOMTests.cpp  			\

UNITTESTPP_SOURCES=\
	../UnitTest++/src/AssertException.cpp 		\
	../UnitTest++/src/Test.cpp 			\
	../UnitTest++/src/Checks.cpp 			\
	../UnitTest++/src/TestRunner.cpp 		\
	../UnitTest++/src/TestResults.cpp 		\
	../UnitTest++/src/TestReporter.cpp 		\
	../UnitTest++/src/TestReporterStdout.cpp 	\
	../UnitTest++/src/ReportAssert.cpp 		\
	../UnitTest++/src/TestList.cpp 			\
	../UnitTest++/src/TimeConstraint.cpp 		\
	../UnitTest++/src/TestDetails.cpp 		\
	../UnitTest++/src/MemoryOutStream.cpp 		\
	../UnitTest++/src/DeferredTestReporter.cpp 	\
	../UnitTest++/src/DeferredTestResult.cpp 	\
	../UnitTest++/src/XmlTestReporter.cpp 		\
	../UnitTest++/src/Win32/TimeHelpers.cpp		\

##############################################################################

CANT2_ARTIFACTS=.\win32

CANT2_APP_OBJS=$(CANT2_ARTIFACTS)\cant2-app.obj
CANT2_APP_BIN=$(CANT2_ARTIFACTS)\cant2-app.bin
CANT2_TEST_OBJS=$(CANT2_ARTIFACTS)\cant2-test.obj
CANT2_TEST_BIN=$(CANT2_ARTIFACTS)\cant2-test.bin

CANT2_APP_EXECUTABLE=$(CANT2_APP_BIN)\cant2.exe
CANT2_TEST_EXECUTABLE=$(CANT2_TEST_BIN)\cant2-test.exe

##############################################################################

all: CAnt2UnitTest $(CANT2_APP_EXECUTABLE)

CAnt2UnitTest: $(CANT2_TEST_EXECUTABLE)
	$(CANT2_TEST_EXECUTABLE)

$(CANT2_APP_EXECUTABLE): $(CANT2_CORE_SOURCES) $(CANT2_MAIN_SOURCES)
	@if not exist $(CANT2_APP_OBJS) mkdir $(CANT2_APP_OBJS)
	@if not exist $(CANT2_APP_BIN) mkdir $(CANT2_APP_BIN)
	$(CPP) $(CANT2_CPPFLAGS) -Fe$@ -Fo$(CANT2_APP_OBJS)\ $**

$(CANT2_TEST_EXECUTABLE): $(CANT2_CORE_SOURCES) $(CANT2_TEST_SOURCES) $(UNITTESTPP_SOURCES)
	@if not exist $(CANT2_TEST_OBJS) mkdir $(CANT2_TEST_OBJS)
	@if not exist $(CANT2_TEST_BIN) mkdir $(CANT2_TEST_BIN)
	$(CPP) $(UNITTESTPP_CPPFLAGS) -I.\cxxtest -I. -Fe$@ -Fo$(CANT2_TEST_OBJS)\ $**

clean:
	@if exist $(CANT2_ARTIFACTS) rmdir /s /q $(CANT2_ARTIFACTS)

